Some integrated software development environments (IDEs) provide a feature referred to as code completion. Generally speaking, code completion is a facility that aids software developers by offering suggestions and/or information applicable to the completion of expressions or statements in a given programming language or paradigm. For example, in the Java™ programming language after a programmer enters an identifier name followed by a dot (‘.’) in a source code editor, code completion could present the programmer with a list of all possible valid names that could follow the dot. This saves the programmer the inconvenience of having to refer to the one or more source code files to determine the correct information. Another example of code completion involves function or method calls. When a programmer types a function/method name in a source code editor, the programmer can be presented with a template of arguments for the function/method, and if there is more than one function/method with the given name, the programmer could be presented with a list of such templates to chose from. When there is only one possible way to complete a given language statement/expression, code completion can simply inscribe the requisite code directly into the source code editor.
Typically, IDEs are implemented using two parsers. One parser is engaged to determine types and methods. A second parser is invoked when code completion is required. The second parser gathers information, typically in the form of a parse tree, by which a code completion facility can determine possible completions of a given expression/statement. This arrangement is inherently inefficient, however, since two parsers are required by an IDE supporting this feature and since a given range of source code will be parsed more than once. An additional consideration in implementing a code completion system is the robustness of error recovery. In an IDE source code editor, statements/expressions are often in an incomplete and improper (from a language definition standpoint) grammatical state. Since code completion depends heavily on information generated by a parser, parsers that do not recover well from errors will hamper this functionality.